{include file="common/header"}

<!-- 编辑器 -->
<script charset="utf-8" src="/Public/library/kindeditor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="/Public/library/kindeditor/lang/zh-CN.js"></script>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
       
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                   <div class="ibox-title">
                        <h5>编辑管理员</h5>
                        <span class="label label-primary pull-right label-primary-cust">
                            <a href="javascript:self.location=document.referrer;" class="fa-lg-cust-a" title="返回上一页">
                                <i class="fa fa-arrow-left fa-lg-cust" aria-hidden="true"></i>
                            </a>
                        </span> 
                    </div>
                    <div class="ibox-content">
                        <div class="alert alert-danger">
                            <b>警告：</b>选择角色组时，选择哪个组，该管理员则拥有角色组相对的功能权限，请谨慎操作
                        </div>
                        <form class="form-horizontal m-t" id="partner" enctype="multipart/form-data">
                            <input type="hidden" name="id" value="<?php echo $admin['id']; ?>">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">管理员帐号：</label>
                                <div class="col-sm-8">
                                    <input name="username" value="<?php echo $admin['username']; ?>" type="text" class="form-control" required="" aria-required="true">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">管理员密码：</label>
                                <div class="col-sm-8">
                                    <input name="password" type="text" class="form-control" required="" aria-required="true">
                                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>不填写密码则为不修改密码</span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">管理员角色：</label>
                                <div class="col-sm-8">
                                    <select class="input-sm form-control input-s-sm inline" name="auth_group_id" style="width:150px;height: 33px;">
                                    <?php foreach ($groups as $key => $value): ?>
                                        <option <?php echo $value['auth_group_id']==$admin['auth_group_id']?'selected="selected"':''; ?> value="<?php echo $value['auth_group_id']; ?>"><?php echo $value['group_name']; ?></option>
                                    <?php endforeach ?>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group form-group-bottom">
                                <div class="col-sm-2 col-sm-offset-3">
                                    <p class="btn btn-primary" onclick="submitAdd();">确定修改</p>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            
            </div>
           
        </div>
    </div>
</body>
{include file="common/footer"}
<script>
    //按钮样式
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});

    //添加会员
    function submitAdd(){
        $.ajax({
            url: "/Admin/Auth/admin_edit",
            data:$('#partner').serialize(),
            type: "POST",
            dataType:'json',
            success: function (d) {
                if(d){
                    if(d.error){
                        swal(d.msg, "", "warning");
                        return false;
                }else{
                        swal(d.msg, "", "success");
                        setTimeout("window.location.href='/admin/Auth/admin_list'",1000);
                        //setTimeout("window.location.reload()",1000);
                    }
                }
            }
        })

    }
</script>
